package yunwo.cn.yzstation.view.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import yunwo.cn.yzstation.R;
import yunwo.cn.yzstation.adapter.DetailsAdapter;
import yunwo.cn.yzstation.adapter.PayTypeAdapter;
import yunwo.cn.yzstation.base.MyBaseActivity;
import yunwo.cn.yzstation.other.PickDialog;
import yunwo.cn.yzstation.other.ShowAnimationDialogUtil;

/**
 * Created by lao on 2017/8/31.
 */

public class DetailsActivity extends MyBaseActivity implements View.OnClickListener{

    private TextView mTitlename;
    private ListView mDetailsLV;
    private List<String> mList;
    private LinearLayout mChoose;
    private TextView mHeadtitle;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
        initEvent();
    }

    @Override
    protected String settiltile() {
        return "报表统计";
    }

    private void initEvent() {
        initdata();
        DetailsAdapter detailsAdapter = new DetailsAdapter(DetailsActivity.this);
        detailsAdapter.addDataAndNotifyDataSetChanged(mList);
        mDetailsLV.setAdapter(detailsAdapter);
    }

    private void initdata() {
        mList = new ArrayList<>();
        mList.add("1"); mList.add("1");mList.add("1"); mList.add("1");

    }

    private void initView() {

        mDetailsLV = (ListView) findViewById(R.id.detailsLV);
        mChoose = (LinearLayout) findViewById(R.id.choose);
        mHeadtitle = (TextView) findViewById(R.id.headtitle);

        mChoose.setOnClickListener(this);
    }

    @Override
    protected int getLayoutRsid() {
        return R.layout.activity_details;
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.choose:
                PickDialog selectPayTypeDialog2 = ShowAnimationDialogUtil.showDialog(
                        DetailsActivity.this, R.layout.activity_pay_type_dialog);
                List<String> list = new ArrayList<>();
                list.add("收货人"); list.add("物流公司");
                initPayTypeDialogView(selectPayTypeDialog2, list, mHeadtitle);
                break;
        }
    }
    private void initPayTypeDialogView(final PickDialog selectPayTypeDialog, final List<String> codeName,
                                        TextView paymentTV) {
        View view = selectPayTypeDialog.getView();
        ListView myListview = (ListView) view.findViewById(R.id.myListview);
        PayTypeAdapter payTypeAdapter = new PayTypeAdapter(DetailsActivity.this, codeName, selectPayTypeDialog, paymentTV, false);
        myListview.setAdapter(payTypeAdapter);
        TextView cancelTV = (TextView) view.findViewById(R.id.cancelTV);
        cancelTV.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                selectPayTypeDialog.dismiss();
            }
        });
    }
}
